﻿<%@ page title="卡会员入口-激活礼品卡" language="C#" masterpagefile="WebSiteMasterPage.master" autoeventwireup="true" inherits="useractivecard, App_Web_tzkydamn" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
    #activecardnum{font-size:16px;font-weight:bold;font-family:Arial;padding:5px;border:1px #980101 solid;width:280px}
    #cardnumtext{font-size:16px;font-weight:bold;font-family:Arial;}
    #formactivecard table{margin:50px auto 20px auto}
    .uipaystate{display:none}
</style>
<script type="text/javascript">
    function __activecard(evt) {
        var r = jsformcheck(evt, "formactivecard");

        if (!r)
            return false; ;
        var v = $card.queryCardByCardNum($("#activecardnum").val().toString().trim());
        if (v.length == 1) {
            //只能激活未激活的卡
            if (parseInt(v[0].state) == 0) {
                //alert("待激活");
                $("#cardnumtext").text("卡号："+$("#activecardnum").val().toString().trim());
                $('#dialogactivecard').dialog({
                    autoOpen: false,
                    width: 560,
                    resizable: false,
                    modal:true,
                    title: "激活卡"
                });
                var v1 = $card.queryCardTypeByCardTypeId(v[0].cardtypeid);
                //alert(v1[0].cardprice);
                //$("#cardprice").text(v1[0].cardprice);
                
                var _TxtTotal_fee=(parseFloat(v1[0].cardprice)*1).toFixed(2);
                $("#paycount").text(_TxtTotal_fee.toString());
                
                //setting alipay form
                $("#TxtSubject").val($("#cardnumtext").text());
                $("#TxtTotal_fee").val(_TxtTotal_fee);
                $("#TxtBody").val("by 用户自行激活");
                $("#TxtCardid").val(v[0].cardid);
                
                
                $('#dialogactivecard').dialog('open');
            }
            else {
                alert("不能激活此卡,因为该卡的状态为："+$card.state2text(parseInt(v[0].state)));
            }
        }
        else {
            alert("不存在卡号为：" + $("#activecardnum").val().toString().trim() + "的卡。");
        }
        return false;
    }

    function __pay() {

        
        $(".uipaystep1").hide();
        $(".uipaystate").show();
        document.getElementById("formsubmitalipay").submit();
    }

    function __payok() {
        location = "usertihuo.aspx";
    }
    
    function __payerror()
    {
        $(".uipaystep1").show();
        $(".uipaystate").hide();
    }
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <form id="formactivecard" onsubmit="javascript:return __activecard(event);">
        <table>
            <tr>
                <td>您要激活的卡号为：</td>
                <td><input type="text" id="activecardnum" name="cardnum" nullabled="false" maxlength="50" datatype="string" alerttext="请输入您要激活的卡号" value="<%=Session["cardnum"].ToString()%>" readonly/></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="submit" value="激活此卡" class="btn" /></td>
            </tr>
        </table>
    </form>
    <div id="dialogactivecard" class="X-dialog">
        <span class="cardnum" id="cardnumtext"></span><br/><br/>
        您需要支付：<span id="paycount"></span>元。
        <br/><br/>
        <div class="uipaystep1">
            <form action="/alipay/default.aspx" method="post" id="formsubmitalipay" target="_blank">
                <input type="hidden" name="TxtSubject" id="TxtSubject"/>
                <input type="hidden" name="TxtTotal_fee" id="TxtTotal_fee" />
                <input type="hidden" name="TxtBody" id="TxtBody"/>
                <input type="hidden" name="TxtCardid" id="TxtCardid"/>
            </form>
            <div class="center"><a href="javascript:__pay()" class="btn2">使用支付宝支付以激活本卡</a></div>
        </div>
        <div class="uipaystate">
            <a href="javascript:__payok()" class="btn">已经支付成功</a>
            <a href="javascript:__payerror()" class="btn">支付失败，重试支付。</a>
        </div>
    </div>
</asp:Content>

